//显示提示信息，obj表示显示信息的对象，info表示显示的内容，direction表示显示位置可选1，2，3，4
var tooltipWrong = function (obj, info, direction) {
    obj.tip({
        background: '#ea4c89',
        color: '#fff',
        direction: direction,
        time: 2,
        content: info
    });
};
//根据正则表达式检查数据 返回值：-1表示空，0表示不满足正则，1表示满足正则
var validateData = function (data, regexp) {
    if (regexp == null) {
        regexp = /^.*$/;
    }
    if (data == null || data.length == 0) {
        return -1;
    }
    if (regexp.test(data)) {
        return 1;
    } else {
        return 0;
    }
};
//ajax异步请求
var ajaxRequest = function (url, params, method, successcallback, errorcallback) {
    if (method == null || method == '') {
        method = 'get';
    }
    $.ajax({
        url: url,
        data: params,
        type: method,
        cache: false,
        dataType: 'json',
        success: successcallback,
        error: errorcallback
    })
};
//延时跳转到url
var timeoutForward = function (url, time) {
    window.setTimeout(function () {
        location.href = url
    }, time);
};
// 刷新验证码
var refreshVcode = function (imgObjId) {
    if (imgObjId == null) {
        imgObjId = 'imgcode';
    }
    var time = new Date().getTime();
    var url = document.getElementById(imgObjId).src;
    document.getElementById(imgObjId).src = url + '?' + time;
};

// 页面初始化操作
jQuery(function ($) {
    $('[data-toggle="tooltip"]').tooltip();
    // 记录vcode
    /*var url = $('#imgcode').attr('src');
     if (url != null) {
     window.vcodeUrl = url.substring(0, url.length - 5);
     }*/
    // 侧边栏初始化
    var docObj = $('#doc');
    $('#' + docObj.attr('data-side-menu-id')).parents('.collapse').addClass('in');
    $('#' + docObj.attr('data-side-menu-id')).addClass('active-menu');
    $('#' + docObj.attr('data-side-menu-toggle-id')).attr('aria-expanded', 'true');
    $('#' + docObj.attr('data-side-menu-toggle-id')).addClass('active-menu');


    //弹出
    $('.iframe').bind('click', function () {
        var self = $(this), url = self.attr('data-url'), width = self.attr('data-width') || 685, height = self.attr('data-height') || 550, title = self.attr('title') || '选择';
        height = $(window).height() < height ? ($(window).height() - 10) : height;
        myDialog.iframe(url, title, width, height);
        return false;
    });

    /*menu active*/
    $('table tr').mouseover(function () {
        $(this).addClass('trhover');
    }).mouseout(function () {
        $(this).removeClass('trhover');
    });

});

